package com.sanwei.taskmanagement.service.impl;

import com.sanwei.taskmanagement.mapper.UserMapper;
import com.sanwei.taskmanagement.model.User;
import com.sanwei.taskmanagement.service.AuthService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AuthServiceImpl implements AuthService {
    @Resource
    private UserMapper userMapper;

    @Override
    public boolean login(String username, String password) {
        User user = userMapper.getUserInfoByUsername(username);
        if (user == null) {
//            throw new RuntimeException("user is not exits");
            return false;
        }
        if (user.getPassword().equals(password)){
            return true;
        }
        return false;
    }

    @Override
    public boolean register(User user) {
        return userMapper.insertUserInfo(user);
    }
}
